package xyz.yuzegod.megawalls.util;

import java.text.DecimalFormat;

public class StringUtils
{
    private static final DecimalFormat coinsFormat;
    
    public static String formattedCoins(final int coins) {
        return StringUtils.coinsFormat.format(coins);
    }
    
    public static String upgradeBar(final int level, final int max) {
        final StringBuffer sb = new StringBuffer("§8");
        for (int i = 0; i < max; ++i) {
            if (i >= level) {
                sb.append("▒");
            }
            else {
                sb.append("█");
            }
        }
        return sb.toString();
    }
    
    public static String percent(final double value) {
        final DecimalFormat decimalFormat = new DecimalFormat("0%");
        return decimalFormat.format(value);
    }
    
    public static String level(final int level) {
        switch (level) {
            case 1: {
                return "I";
            }
            case 2: {
                return "II";
            }
            case 3: {
                return "III";
            }
            case 4: {
                return "IV";
            }
            case 5: {
                return "V";
            }
            default: {
                return "I";
            }
        }
    }
    
    public static String formatLongTime(final long time) {
        final int hour = (int)Math.floor((double)(time / 3600000L));
        final int min = (int)Math.floor((double)(time / 60000L));
        if (hour > 0) {
            return hour + "小时";
        }
        return min + "分钟";
    }
    
    static {
        coinsFormat = new DecimalFormat("#,###");
    }
}
